//
//  UITextField+ToolBar.m
//  尚美酒
//
//  Created by WangXiang on 7/15/14.
//  Copyright (c) 2014 zwtym. All rights reserved.
//

#import "UITextField+ToolBar.h"

@implementation UITextField (ToolBar)

-(void)addTarget:(id)target andDismissAction:(SEL)action
{
    UIToolbar *topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, DEVICE_WIDTH-35, DEVICE_WIDTH, 40)];
    [topView setBarStyle:UIBarStyleDefault];
    UIBarButtonItem *butSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:target action:action];
    [doneButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];// is ios7
    NSArray *buttons = [NSArray arrayWithObjects:butSpace,doneButton, nil];
    [topView setItems:buttons];
    [self setInputAccessoryView:topView];
}


@end
